import { ADMIN_GROUP_NAME } from '@/constants';
import { ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-form';
import { Form } from 'antd';
import { getNodeOptions } from '../Node/api';

export default () => {
  return (
    <>
      <Form.Item noStyle shouldUpdate>
        {(form) => {
          if (form.getFieldValue('name') === ADMIN_GROUP_NAME) return null;
          return (
            <ProFormText
              name="name"
              label="名称"
              rules={[{ required: true, message: '请填写名称' }]}
            />
          );
        }}
      </Form.Item>
      <ProFormSelect
        name="nodes"
        label="节点"
        rules={[{ required: true, message: '请选择节点' }]}
        mode="multiple"
        request={getNodeOptions}
      />
      <ProFormDigit
        label="最大可用CPU(核)"
        name="max_cpu"
        min={1}
        rules={[{ required: true, message: '请填入最大CPU' }]}
      />

      <ProFormDigit
        label="最大可用内存(G)"
        name="max_memory"
        min={1}
        rules={[{ required: true, message: '请填入最大内存' }]}
      />

      <ProFormDigit
        label="最大可用硬盘(G)"
        name="max_disk"
        min={1}
        rules={[{ required: true, message: '请填入最大硬盘' }]}
      />
    </>
  );
};
